import { getDictList } from "@/api/service/dict/utils";
import { DICT_ENUM } from "@/enum/dict.enum";

import { globalOptions } from "./options";

export const getOptions = async (type: DICT_ENUM, moduleName: string) => {
  /* 不存在的时候 */
  if (!globalOptions.value[type]) {
    const data = await getDictList(type);
    globalOptions.value[type] = data;
    return translateOptions(data, moduleName);
  }
  return globalOptions.value[type];
};
